package com.rimi.service.impl;

import com.rimi.bean.Pets;
import com.rimi.commons.CommonResult;
import com.rimi.commons.ResultStatus;
import com.rimi.mapper.PetsMapper;
import com.rimi.service.PetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liHaiYang
 * @version V1.0
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/7/6 10:51
 */
@Service
public class PetsServiceImpl implements PetsService {

    @Autowired
    PetsMapper petsMapper;


    @Override
    public CommonResult addPets(Pets pets) {
        int row = petsMapper.addPets(pets);
        return row == 1? CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.ADD_FAILED);
    }

    @Override
    public List<Pets> findPetsByUserId(Integer userId) {
       return petsMapper.showPetsByUserId(userId);
    }

    @Override
    public CommonResult deletePetsByPetId(Integer petId) {
        int row = petsMapper.deletePetsByPetId(petId);
        return row == 1? CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.DELETE_FAILED);
    }

    @Override
    public CommonResult updatePets(Pets pets) {
        int row = petsMapper.updatePets(pets);
        return row == 1? CommonResult.onSuccess(null):CommonResult.onFailed(ResultStatus.UPDATE_FAILED);
    }

    @Override
    public int upLoadImg(String imgurl, Integer petId) {
        return petsMapper.upLoadImg(imgurl,petId);
    }


}
